package com.gallop.akka;

import akka.actor.*;
import akka.cluster.sharding.ShardRegion;
import lombok.Builder;
import lombok.Getter;

import java.util.List;
import java.util.function.Function;

public interface ActorContextSupport {

    ActorRef actorOf(Class<? extends Actor> actorClass);

    ActorRef actorOf(Class<? extends Actor> actorClass, Object... args);

    ActorRef actorOf(ActorContext parentContext, Class<? extends Actor> actorClass, Object... args);

    ActorRef actorOf(ActorParam actorParam);

    ActorRef singletonOf(Class<? extends Actor> actorClass, Object terminationMessage,
                         Object... args);

    ActorRef singletonOf(Class<? extends Actor> actorClass, Object terminationMessage);

    ActorRef clusterShardingOf(Class<? extends Actor> actorClass, ShardRegion.MessageExtractor messageExtractor);

    ActorSelection actorSelection(String path);

    ActorSelection actorSelection(ActorContext context, String path);

    @Getter
    @Builder
    class ActorParam {
        private ActorContext parentContext;
        private Class<? extends Actor> actorClass;
        private String actorName;
        private List<Object> args;
        private Function<Props, Props> propDecorator;
    }
}
